-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Ensure hasComputedSubKeys iterates over Sets and Lists properly #9171
core: Ensure hasComputedSubKeys iterates over Sets and Lists properly #9171
Conversation
About to remove the WIP, however going to throw a test that does not see to be working in the gist below: https://gist.github.com/vancluever/b0c52e5da0193d6a24b0a326d7117c6c The test fails with:
@radeksimko maybe related to #7485 and #7393? |
This fixes some edge-ish cases where a set in a config has a set or list in it that contains computed values, but non-set or list values in the parent do not. This can cause "diffs didn't match during apply" errors in a scenario such as when a set's hash is calculated off of child items (including any sub-lists or sets, as it should be), and the hash changes between the plan and apply diffs due to the computed values present in the sub-list or set items. These will be marked as computed, but due to the fact that the function was not iterating over the list or set items properly (ie: not adding the item number to the address, so set.0.set.foo was being yielded instead of set.0.set.0.foo), these computed values were not being properly propagated to the parent set to be marked as computed. Fixes #6527. Fixes #8271. This possibly fixes other non-CloudFront related issues too.
This covers: * Complex sets with computed fields in a set * Complex lists with computed fields in a set Adding a test to test basic lists with computed fields seemed to fail, but possibly for an unrelated reason (the list returned as nil). The fix to this inparticular case may be out of the scope of this specific issue. Reference gist and details in #9171.
Needed due to work done in 95d37ea, we may need to adjust hasComputedSubKeys to propagate NewComputed in the same way that we have added "~", however will wait for comment from @mitchellh.
I've updated this PR with a a rebase and a slight update to the tests. @mitchellh, I noticed that the necessary updates to the tests were probably needed due to work done in 95d37ea and related commits - is this PR still relevant in the face of that work? Here's an example of a one of the failing tests post-commit:
One thing that I'm noticing here too is that maybe where we are marking the parents with |
@vancluever Great job, great tests. I added some tests to I think as you said having NewComputed on the outer key MAY be more correct but at the moment this makes a fully working thing (according to the tests) so that may be an optimization we want to make in the future but for now might be okay. Thanks for your work on this! |
@mitchellh fair enough and thanks for the merge and the feedback! Glad to help as always :) |
This covers: * Complex sets with computed fields in a set * Complex lists with computed fields in a set Adding a test to test basic lists with computed fields seemed to fail, but possibly for an unrelated reason (the list returned as nil). The fix to this inparticular case may be out of the scope of this specific issue. Reference gist and details in hashicorp#9171.
This covers: * Complex sets with computed fields in a set * Complex lists with computed fields in a set Adding a test to test basic lists with computed fields seemed to fail, but possibly for an unrelated reason (the list returned as nil). The fix to this inparticular case may be out of the scope of this specific issue. Reference gist and details in hashicorp#9171.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
WIP - Adding tests to this :)